/*
 * @Description: 数组与指针
 * @Version: 1.0
 * @Author: marshal
 * @Date: 2022-06-20 10:42:11
 * @LastEditors: marshal
 * @LastEditTime: 2022-06-20 13:59:24
 */
#include <stdio.h>
#define LEN 3

int_sum(const int arr[], int n);

int main(int argc, char const *argv[])
{
    int a[] = {1, 3, 5};
    // note: the name of an array is the address of its first element
    // 数组的变量名表示的是数组第一个元素的地址，就相当于是指针，所以可以使用 *a 这种方式来获取数组的第一个元素
    printf("a[0] = %d\n", *a);
    printf("a[1] = %d\n", *(a + 1));
    printf("a[2] = %d\n", *(a + 2));
}

int_sum(const int arr[], int n)
{
    int i;
    int sum = 0;
    for (i = 0; i < n; i++)
    {
        sum += arr[i];
    }
    return sum;
}